Some image forming apparatuses that form an image electrophotographically include an optical scanning mechanism having a rotary polygon mirror which deflects a light beam emitted from a light source to illuminate a photosensitive member. A brushless motor is sometimes used as a driving motor for rotating the rotary polygon mirror. In a brushless motor, it is necessary to detect a position of a rotor to control energization timing for each coil. There has been proposed a known image forming apparatus, in which a plurality of Hall elements are placed in a vicinity of the rotor, and the position of the rotor is detected based on output signals of Hall elements.